package cn.dengta.webapp.user.vo;

import java.util.Map;
import javax.annotation.Nullable;

import cn.dengta.common.model.Status;
import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.user.entity.AskContact;
import cn.dengta.webapp.user.model.AskContactType;
import cn.dengta.webapp.user.model.ContactType;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.X;

/**
 * 联系方式
 */
@Setter
@Getter
@Accessors(chain = true)
public class AskContactVO extends AbstractVO<AskContact> {

	/** 账号 */
	String account;
	/** 来源渠道 */
	String channel;
	/** ip */
	String addIp;
	/** 归属人 */
	String belong;
	/** 状态 */
	Integer status;
	/** 类型：0=官方；1=女主播 */
	AskContactType type;
	/** 成员ID */
	Long empId;
	/** 成员 */
	Map<String, Object> emp;
	/** 联系方式 */
	public ContactType contactType;

	public static String[] frontList = { "type", "addIp", "status", "addTime" };

	public static AskContactVO from(@Nullable AskContact source) {
		return copy(source, AskContactVO::new);
	}

	public static AskContactVO from(@Nullable AskContactVO source) {
		if (source != null) {
			AskContactVO vo = new AskContactVO().setAccount(source.getAccount()).setContactType(source.contactType);
			vo.setId(source.getId());
			return vo;
		}
		return null;
	}

	public static AskContactVO fromFront(@Nullable AskContact source) {
		return copy(source, AskContactVO::new, frontList);
	}

	public Integer getType() {
		return X.map(type, AskContactType::getValue);
	}

	public String getType_() {
		return X.map(type, AskContactType::getLabel);
	}

	public Integer getContactType() {
		return X.map(contactType, ContactType::getValue);
	}

	public String getContactType_() {
		return X.map(contactType, ContactType::getLabel);
	}

	public String getAddTime_() {
		return super.getAddTime_();
	}

	public String getStatus_() {
		return super.getStatus_(status);
	}

	public String getContactStatus_() {
		return status == null ? null : Status.asResult(status) ? "已联系" : "待联系";
	}

}
